﻿namespace YXYLCommon
{
    /// <summary>
    /// 用户表示操作结果的类.封装内容:操作码(-1 失败,1 成功),操作返回消息,操作是否成功
    /// </summary>
    public class DbCmdResult
    {
        public DbCmdResult()
        { }
        
        /// <summary>
        /// 指定操作结果实例化
        /// </summary>
        public DbCmdResult(bool issuccess)
        {
            this.IsSuccess = issuccess;
        }
        public DbCmdResult(bool issuccess,string msg)
        {
            this.IsSuccess = issuccess;
            this.returnMsg = msg;
        }

        private int returnNo = 1;

        public int ReturnNo
        {
            get { return returnNo; }
            set { returnNo = value; }
        }
        private string returnMsg = "操作成功!";

        /// <summary>
        /// 操作成功,返回后续程序需要操作的关联数据,以"|"分隔.操作失败,返回失败原因
        /// </summary>
        public string ReturnMsg
        {
            get { return returnMsg; }
            set { returnMsg = value; }
        }

        public bool IsSuccess
        {
            get
            {
                if (this.returnNo > 0)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            set
            {
                if (value)
                {
                    this.returnNo = 1;
                    this.returnMsg = "OK";
                }
                else
                {
                    this.returnNo = -1;
                    this.returnMsg = "ERROR";
                }
            }
        }   

        
    }
}
